<?php
# auth.php
# Copyright (C) Vincenzo Tilotta 2011 <tailot@gmail.com>
#
# auth.php is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# auth.php is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.

# You should have received a copy of the GNU General Public License along
# with this program.  If not, see <http://www.gnu.org/licenses/>.
if(isset($_POST['u']) and isset($_POST['p']) and $_POST['p'] != '' and $_POST['u'] != ''){
	if(!file_exists("users/".$_POST['u'])){
		mkdir("users/".$_POST['u']);
		file_put_contents("users/".$_POST['u']."/"."pw.pubkey",$_POST['p']);
		/*
		system("openssl genrsa -out "."users/".$_POST['u']."/"."pkey.key"." 2048");
		system("openssl rsa -in "."users/".$_POST['u']."/"."pkey.key"." -pubout -out "."users/".$_POST['u']."/pub.key"."");
		echo file_get_contents("users/".$_POST['u']."/pub.key");
		*/
		echo "1";
		exit;
	}
}
echo "0";
?>
